package com.hedl.practice.diyJava.gather.study_stack.practice.test;

import java.util.Deque;
import java.util.LinkedList;

public class DecimalConversion {
    public static void main(String[] args) {
        String hex = toHex(12500);
        int hexs = 12500;
        if (hex.equalsIgnoreCase("30D4")){
            System.out.println("测试通过！");
        }else {
            System.out.println("测试失败！");
        }
    }

    private static String toHex(int i) {
        Deque<Object> deque = new LinkedList<>();
        StringBuilder s = new StringBuilder();
        char[] b = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
        while (i != 0){
            deque.push(b[i%16]);
            i = i / 16;
        }
        for (int a = deque.size();a > 0;a--){
            s.append(deque.pop());
        }
        return s.toString();
    }


}
